<template>
    <a-row class="text-center clearfix btn-box">
        <a-col class="btn-item" v-if="btnPermission('list')">
            <div class="btns" @click="switchList('list')" v-if="showModel=='order'">
                <a-icon class="btns-icon" type="unordered-list" />
                <div class="btns-text">列表</div>
            </div>
            <div class="btns" @click="switchList('order')" v-else>
                <a-icon class="btns-icon" type="container" />
                <div class="btns-text">单据</div>
            </div>
        </a-col>

        <a-col :class="{btnItem: btnPermission('add')}" v-if="btnPermission('add')">
            <!--新增-->
            <slot name="neworder"></slot>
        </a-col>

        <a-col class="btn-item" :class="editMask==false?'':'btns-disable'" v-if="btnPermission('save')">
            <div v-if="showModel=='order'">
                <div class="btns" @click="editMask==false?submitServer():''">
                    <a-icon class="btns-icon" type="save" />
                    <div class="btns-text">保存</div>
                </div>
            </div>
            <div v-else class="btns-disable">
                <div class="btns">
                    <a-icon class="btns-icon" type="save" />
                    <div class="btns-text">保存</div>
                </div>
            </div>
        </a-col>

        <a-col class="btn-item" :class="(voucherState==-1 || (notSubmitArray.includes(path) && voucherState == 0)) && editMask==true?'':'btns-disable'" v-if="btnPermission('edit')">
            <div v-if="showModel=='order'">
                <div class="btns" @click="(voucherState==-1 || (notSubmitArray.includes(path)  && voucherState == 0)) && editMask==true?clickEdit():''">
                    <a-icon class="btns-icon" type="edit" />
                    <div class="btns-text">修改</div>
                </div>
            </div>
            <div v-else class="btns-disable">
                <div class="btns">
                    <a-icon class="btns-icon" type="edit" />
                    <div class="btns-text">修改</div>
                </div>
            </div>
        </a-col>

        <a-col class="btn-item" :class="editMask==true && orderId && (voucherState==-1 || (notSubmitArray.includes(path)  && voucherState == 0))?'':'btns-disable'" v-if="btnPermission('delete')">
            <div v-if="showModel=='order'">
                <div class="btns" @click="editMask==true && orderId && (voucherState==-1 || (notSubmitArray.includes(path)  && voucherState == 0))?deleteOrder():''">
                    <a-icon class="btns-icon" type="delete" />
                    <div class="btns-text">删除</div>
                </div>
            </div>
            <div v-else class="btns-disable">
                <div class="btns">
                    <a-icon class="btns-icon" type="delete" />
                    <div class="btns-text">删除</div>
                </div>
            </div>
        </a-col>

        <a-col class="btn-item" v-if="!hideRevocation" :class="editMask==false?'':'btns-disable'">
            <div class="btns" @click="editMask==false?getIdByData():''">
                <a-icon class="btns-icon" type="undo" />
                <div class="btns-text">撤销</div>
            </div>
        </a-col>
        <!-- <a-col class="btn-item">
            <slot name="hebing"></slot>
        </a-col>
        <a-col class="btn-item">
            <slot name="chaifen"></slot>
        </a-col> -->
        <a-col class="btn-item" :class="orderId && createUserId==userInfo.id && voucherState==-1?'':'btns-disable'" v-if="btnPermission('applyOut')">
            <div v-if="showModel=='order'">
                <div class="btns" @click="orderId && createUserId==userInfo.id && voucherState==-1 ?auditClick(1):''">
                    <a-icon class="btns-icon" type="audit" />
                    <div class="btns-text">申请出库</div>
                </div>
            </div>
            <div v-else class="btns-disable">
                <div class="btns">
                    <a-icon class="btns-icon" type="audit" />
                    <div class="btns-text">申请出库</div>
                </div>
            </div>
        </a-col>

        <a-col class="btn-item" :class="orderId && createUserId==userInfo.id && voucherState==-1?'':'btns-disable'" v-if="btnPermission('applyIn')">
            <div v-if="showModel=='order'">
                <div class="btns" @click="orderId && createUserId==userInfo.id && voucherState==-1 ?auditClick(1):''">
                    <a-icon class="btns-icon" type="audit" />
                    <div class="btns-text">申请入库</div>
                </div>
            </div>
            <div v-else class="btns-disable">
                <div class="btns">
                    <a-icon class="btns-icon" type="audit" />
                    <div class="btns-text">申请入库</div>
                </div>
            </div>
        </a-col>

        <a-col class="btn-item" :class="voucherState!==1?'btns-disable':''" v-if="btnPermission('change')">
            <div v-if="showModel=='order'">
                <div class="btns" @click="voucherState!==1?'':bgChange()">
                    <a-icon class="btns-icon" type="snippets" />
                    <div class="btns-text">变更</div>
                </div>
            </div>
            <div v-else class="btns-disable">
                <div class="btns">
                    <a-icon class="btns-icon" type="snippets" />
                    <div class="btns-text">变更</div>
                </div>
            </div>
        </a-col>

        <a-col class="btn-item" v-if="btnPermission('submitOrder')" :class="voucherState >= 1 || !editMask ?'btns-disable':''">
            <!--提交-->
            <a-dropdown v-if="showModel=='order'" class="btns" key="submit" style="display:block">
                <a class="ant-dropdown-link" @click="e => e.preventDefault()">
                    <a-icon class="btns-icon" type="check-circle" />
                    <div class="btns-text">提交
                        <a-icon type="down" style="vertical-align:middle;" />
                    </div>
                </a>
                <a-menu slot="overlay">
                    <a-menu-item key="0">
                        <a href="javascript:void(0)" @click="voucherState == -1 && editMask ?submitOrder(0):''">
                            <span :class="voucherState == -1 && editMask?'':'color-gray'">提交</span>
                        </a>
                    </a-menu-item>
                    <a-menu-item key="1">
                        <a href="javascript:void(0)" @click="voucherState == 0 ?submitOrder(-1):''">
                            <span :class="voucherState == 0 ?'':'color-gray'">撤回提交</span>
                        </a>
                    </a-menu-item>
                </a-menu>
            </a-dropdown>
            <div v-else class="btns-disable">
                <a-dropdown class="btns" key="submit" style="display:block">
                    <a class="ant-dropdown-link" @click="e => e.preventDefault()">
                        <a-icon class="btns-icon" type="check-circle" />
                        <div class="btns-text">提交
                            <a-icon type="down" style="color:#ccc;vertical-align:middle;" />
                        </div>
                    </a>
                    <a-menu slot="overlay">
                        <a-menu-item key="0">
                            <a href="javascript:void(0)">
                                <span class="color-gray">提交</span>
                            </a>
                        </a-menu-item>
                        <a-menu-item key="1">
                            <a href="javascript:void(0)">
                                <span class="color-gray">撤回提交</span>
                            </a>
                        </a-menu-item>
                    </a-menu>
                </a-dropdown>
            </div>
        </a-col>

        <a-col class="btn-item" v-if="!isSource && btnPermission('examine')" :class="voucherState == 0 || voucherState == 1 ?'':'btns-disable'">
            <!--审核 弃审-->
            <a-dropdown v-if="showModel=='order'" class="btns" key="examine" style="display:block">
                <a class="ant-dropdown-link" @click="e => e.preventDefault()">
                    <a-icon class="btns-icon" type="audit" />
                    <div class="btns-text">审核
                        <a-icon type="down" style="vertical-align:middle;" />
                    </div>
                </a>
                <a-menu slot="overlay">
                    <a-menu-item key="0">
                        <a href="javascript:void(0)" @click="editMask==true && voucherState==0 && orderId?auditClick(1):''">
                            <span :class="editMask==true && voucherState==0 && orderId?'':'color-gray'">审核</span>
                        </a>
                    </a-menu-item>
                    <a-menu-item key="0">
                        <a href="javascript:void(0)" @click="editMask==true && voucherState==1 && orderId?auditClick(0):''">
                            <span :class="editMask==true && voucherState==1 && orderId?'':'color-gray'">弃审</span>
                        </a>
                    </a-menu-item>
                </a-menu>
            </a-dropdown>
            <div v-else class="btns-disable">
                <a-dropdown class="btns" key="examine" style="display:block">
                    <a class="ant-dropdown-link" @click="e => e.preventDefault()">
                        <a-icon class="btns-icon" type="audit" />
                        <div class="btns-text">审核
                            <a-icon type="down" style="color:#ccc;vertical-align:middle;" />
                        </div>
                    </a>
                    <a-menu slot="overlay">
                        <a-menu-item key="0">
                            <a href="javascript:void(0)">
                                <span class="color-gray">审核</span>
                            </a>
                        </a-menu-item>
                        <a-menu-item key="0">
                            <a href="javascript:void(0)">
                                <span class="color-gray">弃审</span>
                            </a>
                        </a-menu-item>
                    </a-menu>
                </a-dropdown>
            </div>
        </a-col>
        <a-col>
            <slot name="yunsuan"></slot>
        </a-col>
        
        
        <!-- <a-col class="btn-item" :class="editMask==true  && voucherState==0 && orderId?'':'btns-disable'" v-if="!isSource && btnPermission('examine')">
            <div v-if="showModel=='order'">
                <div class="btns" @click="editMask==true && voucherState==0 && orderId?auditClick(1):''">
                    <a-icon class="btns-icon" type="audit" />
                    <div class="btns-text">审核</div>
                </div>
            </div>
            <div v-else class="btns-disable">
                <div class="btns">
                    <a-icon class="btns-icon" type="audit" />
                    <div class="btns-text">审核</div>
                </div>
            </div>
        </a-col>

        <a-col class="btn-item" :class="voucherState==1 && orderId?'':'btns-disable'" v-if="!isSource && btnPermission('examine')">
            <div v-if="showModel=='order'">
                <div class="btns" @click="voucherState==1 && orderId?auditClick(0):''">
                    <a-icon class="btns-icon" type="audit" />
                    <div class="btns-text">弃审</div>
                </div>
            </div>
            <div v-else class="btns-disable">
                <div class="btns">
                    <a-icon class="btns-icon" type="audit" />
                    <div class="btns-text">弃审</div>
                </div>
            </div>
        </a-col> -->

        <a-col class="btn-item" :class="editMask==true  && voucherState==1 && orderId?'':'btns-disable'" v-if="!isSource && btnPermission('ratify')">
            <div v-if="showModel=='order'">
                <div class="btns" @click="editMask==true && voucherState==1 && orderId?approvalClick(2):''">
                    <a-icon class="btns-icon" type="audit" />
                    <div class="btns-text">批准</div>
                </div>
            </div>
            <div v-else class="btns-disable">
                <div class="btns">
                    <a-icon class="btns-icon" type="audit" />
                    <div class="btns-text">批准</div>
                </div>
            </div>
        </a-col>

        <a-col class="btn-item" :class="editMask==true  && voucherState==2 && orderId?'':'btns-disable'" v-if="!isSource && btnPermission('ratify')">
            <div v-if="showModel=='order'">
                <div class="btns" @click="editMask==true && voucherState==2 && orderId?approvalClick(1):''">
                    <a-icon class="btns-icon" type="audit" />
                    <div class="btns-text">取消批准</div>
                </div>
            </div>
            <div v-else class="btns-disable">
                <div class="btns">
                    <a-icon class="btns-icon" type="audit" />
                    <div class="btns-text">取消批准</div>
                </div>
            </div>
        </a-col>

        <a-col class="btn-item" :class="editMask==true  && !enableState && orderId?'':'btns-disable'" v-if="!isSource && btnPermission('enable')">
            <div v-if="showModel=='order'">
                <div class="btns" @click="editMask==true && !enableState && orderId?changeEnableState(true):''">
                    <a-icon class="btns-icon" type="audit" />
                    <div class="btns-text">启用</div>
                </div>
            </div>
            <div v-else class="btns-disable">
                <div class="btns">
                    <a-icon class="btns-icon" type="audit" />
                    <div class="btns-text">启用</div>
                </div>
            </div>
        </a-col>

        <a-col class="btn-item" :class="editMask==true  && enableState && orderId?'':'btns-disable'" v-if="!isSource && btnPermission('enable')">
            <div v-if="showModel=='order'">
                <div class="btns" @click="editMask==true && enableState && orderId?changeEnableState(false):''">
                    <a-icon class="btns-icon" type="audit" />
                    <div class="btns-text">停用</div>
                </div>
            </div>
            <div v-else class="btns-disable">
                <div class="btns">
                    <a-icon class="btns-icon" type="audit" />
                    <div class="btns-text">停用</div>
                </div>
            </div>
        </a-col>

        <a-col class="btn-item" :class="editMask==true  && voucherState==2 && orderId?'':'btns-disable'" v-if="!isSource && btnPermission('allot')">
            <div v-if="showModel=='order'">
                <div class="btns" @click="editMask==true && voucherState==2 && orderId?allotClick():''">
                    <a-icon class="btns-icon" type="audit" />
                    <div class="btns-text">调拨</div>
                </div>
            </div>
            <div v-else class="btns-disable">
                <div class="btns">
                    <a-icon class="btns-icon" type="audit" />
                    <div class="btns-text">调拨</div>
                </div>
            </div>
        </a-col>

        <!--操作员销售发货单 专属-->
        <a-col class="btn-item" :class="voucherState==1 && orderId?'':'btns-disable'" v-if="sourceCode == 'SaleDelivery' && btnPermission('submit')">
            <div v-if="showModel=='order'">
                <div class="btns" @click="voucherState==1 && orderId?submitClick():''">
                    <a-icon class="btns-icon" type="check-circle" />
                    <div class="btns-text">提交</div>
                </div>
            </div>
            <div v-else class="btns-disable">
                <div class="btns">
                    <a-icon class="btns-icon" type="check-circle" />
                    <div class="btns-text">提交</div>
                </div>
            </div>
        </a-col>
        <!--库管员销售发货单 专属-->
        <a-col class="btn-item" :class="voucherState==2 && orderId?'':'btns-disable'" v-if="sourceCode == 'SaleDelivery' && btnPermission('return')">
            <div v-if="showModel=='order'">
                <div class="btns" @click="voucherState==2 && orderId?submitClick():''">
                    <a-icon class="btns-icon" type="snippets" />
                    <div class="btns-text">退单</div>
                </div>
            </div>
            <div v-else class="btns-disable">
                <div class="btns">
                    <a-icon class="btns-icon" type="snippets" />
                    <div class="btns-text">退单</div>
                </div>
            </div>
        </a-col>

        <!--操作员领料单 专属-->
        <a-col class="btn-item" :class="voucherState==1 && orderId?'':'btns-disable'" v-if="(sourceCode == 'RRS' || sourceCode == 'DelegateRRS') && btnPermission('picking')">
            <div v-if="showModel=='order'">
                <div class="btns" @click="voucherState==1 && orderId?submitClick():''">
                    <a-icon class="btns-icon" type="snippets" />
                    <div class="btns-text">{{isRefund?'退料':'领料'}}</div>
                </div>
            </div>
            <div v-else class="btns-disable">
                <div class="btns">
                    <a-icon class="btns-icon" type="snippets" />
                    <div class="btns-text">{{isRefund?'退料':'领料'}}</div>
                </div>
            </div>
        </a-col>
        <!--调拨单退单 专属-->
        <a-col class="btn-item" :class="voucherState==2 && orderId?'':'btns-disable'" v-if="sourceCode == 'InventoryAllocation' && btnPermission('return')">
            <div v-if="showModel=='order'">
                <div class="btns" @click="voucherState==2 && orderId?returnBack():''">
                    <a-icon class="btns-icon" type="snippets" />
                    <div class="btns-text">退单</div>
                </div>
            </div>
            <div v-else class="btns-disable">
                <div class="btns">
                    <a-icon class="btns-icon" type="snippets" />
                    <div class="btns-text">退单</div>
                </div>
            </div>
        </a-col>

        <!--库管员 领料单退单 专属-->
        <a-col class="btn-item" :class="voucherState==2 && orderId?'':'btns-disable'" v-if="(sourceCode == 'RRS' || sourceCode == 'DelegateRRS') && btnPermission('return')">
            <div v-if="showModel=='order'">
                <div class="btns" @click="voucherState==2 && orderId?submitClick():''">
                    <a-icon class="btns-icon" type="snippets" />
                    <div class="btns-text">退单</div>
                </div>
            </div>
            <div v-else class="btns-disable">
                <div class="btns">
                    <a-icon class="btns-icon" type="snippets" />
                    <div class="btns-text">退单</div>
                </div>
            </div>
        </a-col>

        <a-col class="btn-item" :class="voucherState==1 && orderId && createUserId==userInfo.id?'':'btns-disable'" v-if="sourceCode != 'SaleDelivery' && isSource && btnPermission('return')">
            <div v-if="showModel=='order'">
                <div class="btns" @click="voucherState==1 && orderId && createUserId==userInfo.id?auditClick(0):''">
                    <a-icon class="btns-icon" type="snippets" />
                    <div class="btns-text">退单</div>
                </div>
            </div>
            <div v-else class="btns-disable">
                <div class="btns">
                    <a-icon class="btns-icon" type="snippets" />
                    <div class="btns-text">退单</div>
                </div>
            </div>
        </a-col>
        <!-- <a-col class="btn-item" :class="voucherState==1?'':'btns-disable'" v-if="btnPermission('confirmIn')">
            <div v-if="showModel=='order'">
                <div class="btns" @click="voucherState==1?theGoods(1):''">
                    <a-icon class="btns-icon" type="gold" />
                    <div class="btns-text">入库</div>
                </div>
            </div>
            <div v-else class="btns-disable">
                <div class="btns">
                    <a-icon class="btns-icon" type="gold" />
                    <div class="btns-text">入库</div>
                </div>
            </div> -->
        <a-col class="btn-item" v-if="!isSource && btnPermission('confirmIn')" :class="voucherState == 1 || voucherState == 2 ?'':'btns-disable'">
            <!--入库修改后的入库 出库-->
            <a-dropdown v-if="showModel=='order'" class="btns"  style="display:block">
                <a class="ant-dropdown-link" @click="e => e.preventDefault()">
                    <a-icon class="btns-icon" type="gold" />
                    <div class="btns-text">入库
                        <a-icon type="down" style="vertical-align:middle;" />
                    </div>
                </a>
                <a-menu slot="overlay">
                    <a-menu-item key="0">
                        <a href="javascript:void(0)" @click="voucherState==1?theGoods(1):''">
                            <span :class="editMask==true && voucherState==1 && orderId?'':'color-gray'">入库</span>
                        </a>
                    </a-menu-item>
                    <a-menu-item key="0">
                        <a href="javascript:void(0)" @click="voucherState==2?theGoods(2):''">
                            <span :class="editMask==true && voucherState==2 && orderId?'':'color-gray'">撤销入库</span>
                        </a>
                    </a-menu-item>
                </a-menu>
            </a-dropdown>
            <div v-else class="btns-disable">
                <a-dropdown class="btns"  style="display:block">
                    <a class="ant-dropdown-link" @click="e => e.preventDefault()">
                        <a-icon class="btns-icon" type="audit" />
                        <div class="btns-text">入库
                            <a-icon type="down" style="color:#ccc;vertical-align:middle;" />
                        </div>
                    </a>
                    <a-menu slot="overlay">
                        <a-menu-item key="0">
                            <a href="javascript:void(0)">
                                <span class="color-gray">入库</span>
                            </a>
                        </a-menu-item>
                        <a-menu-item key="0">
                            <a href="javascript:void(0)">
                                <span class="color-gray">撤销入库</span>
                            </a>
                        </a-menu-item>
                    </a-menu>
                </a-dropdown>
            </div>

        </a-col>
        <!-- <a-col class="btn-item" :class="voucherState==1?'':'btns-disable'" v-if="btnPermission('confirmInRet')">
            <div v-if="showModel=='order'">
                <div class="btns" @click="voucherState==1?theGoods(2):''">
                    <a-icon class="btns-icon" type="gold" />
                    <div class="btns-text">退货出库</div>
                </div>
            </div>
            <div v-else class="btns-disable">
                <div class="btns">
                    <a-icon class="btns-icon" type="gold" />
                    <div class="btns-text">退货出库</div>
                </div>
            </div>
        </a-col> -->
        <a-col class="btn-item" v-if="!isSource && btnPermission('confirmInRet')" :class="voucherState == 1 || voucherState == 2 ?'':'btns-disable'">
            <!--退货出库修改后的入库 出库 -->
            <a-dropdown v-if="showModel=='order'" class="btns"  style="display:block">
                <a class="ant-dropdown-link" @click="e => e.preventDefault()">
                    <a-icon class="btns-icon" type="gold" />
                    <div class="btns-text">退货
                        <a-icon type="down" style="vertical-align:middle;" />
                    </div>
                </a>
                <a-menu slot="overlay">
                    <a-menu-item key="0">
                        <a href="javascript:void(0)" @click="voucherState==1?theGoods(2):''">
                            <span :class="editMask==true && voucherState==1 && orderId?'':'color-gray'">退货出库</span>
                        </a>
                    </a-menu-item>
                    <a-menu-item key="0">
                        <a href="javascript:void(0)" @click="voucherState==2?theGoods(3):''">
                            <span :class="editMask==true && voucherState==2 && orderId?'':'color-gray'">撤销出库</span>
                        </a>
                    </a-menu-item>
                </a-menu>
            </a-dropdown>
            <div v-else class="btns-disable">
                <a-dropdown class="btns"  style="display:block">
                    <a class="ant-dropdown-link" @click="e => e.preventDefault()">
                        <a-icon class="btns-icon" type="audit" />
                        <div class="btns-text">退货出库
                            <a-icon type="down" style="color:#ccc;vertical-align:middle;" />
                        </div>
                    </a>
                    <a-menu slot="overlay">
                        <a-menu-item key="0">
                            <a href="javascript:void(0)">
                                <span class="color-gray">退货出库</span>
                            </a>
                        </a-menu-item>
                        <a-menu-item key="0">
                            <a href="javascript:void(0)">
                                <span class="color-gray">撤销出库</span>
                            </a>
                        </a-menu-item>
                    </a-menu>
                </a-dropdown>
            </div>

        </a-col>


        <!-- <a-col class="btn-item" :class="voucherState==1?'':'btns-disable'" v-if="btnPermission('confirmOut')">
            <div v-if="showModel=='order'">
                <div class="btns" @click="voucherState==1?theGoods(2):''">
                    <a-icon class="btns-icon" type="gold" />
                    <div class="btns-text">出库</div>
                </div>
            </div>
            <div v-else class="btns-disable">
                <div class="btns">
                    <a-icon class="btns-icon" type="gold" />
                    <div class="btns-text">出库</div>
                </div>
            </div>
        </a-col> -->
       <a-col class="btn-item" v-if="!isSource && btnPermission('confirmOut')" :class="voucherState == 1 || voucherState == 2 ?'':'btns-disable'">
            <!--出库修改后的入库 出库 -->
            <a-dropdown v-if="showModel=='order'" class="btns"  style="display:block">
                <a class="ant-dropdown-link" @click="e => e.preventDefault()">
                    <a-icon class="btns-icon" type="gold" />
                    <div class="btns-text">出库
                        <a-icon type="down" style="vertical-align:middle;" />
                    </div>
                </a>
                <a-menu slot="overlay">
                    <a-menu-item key="0">
                        <a href="javascript:void(0)" @click="voucherState==1?theGoods(2):''">
                            <span :class="editMask==true && voucherState==1 && orderId?'':'color-gray'">出库</span>
                        </a>
                    </a-menu-item>
                    <a-menu-item key="0">
                        <a href="javascript:void(0)" @click="voucherState==2?theGoods(3):''">
                            <span :class="editMask==true && voucherState==2 && orderId?'':'color-gray'">撤销出库</span>
                        </a>
                    </a-menu-item>
                </a-menu>
            </a-dropdown>
            <div v-else class="btns-disable">
                <a-dropdown class="btns"  style="display:block">
                    <a class="ant-dropdown-link" @click="e => e.preventDefault()">
                        <a-icon class="btns-icon" type="audit" />
                        <div class="btns-text">出库
                            <a-icon type="down" style="color:#ccc;vertical-align:middle;" />
                        </div>
                    </a>
                    <a-menu slot="overlay">
                        <a-menu-item key="0">
                            <a href="javascript:void(0)">
                                <span class="color-gray">出库</span>
                            </a>
                        </a-menu-item>
                        <a-menu-item key="0">
                            <a href="javascript:void(0)">
                                <span class="color-gray">撤销出库</span>
                            </a>
                        </a-menu-item>
                    </a-menu>
                </a-dropdown>
            </div>

        </a-col>


        <!-- <a-col class="btn-item" :class="voucherState==1?'':'btns-disable'" v-if="btnPermission('comfirmOutRet')">
            <div v-if="showModel=='order'">
                <div class="btns" @click="voucherState==1?theGoods(3):''">
                    <a-icon class="btns-icon" type="gold" />
                    <div class="btns-text">退货入库</div>
                </div>
            </div>
            <div v-else class="btns-disable">
                <div class="btns">
                    <a-icon class="btns-icon" type="gold" />
                    <div class="btns-text">退货入库</div>
                </div>
            </div>
        </a-col> -->
       <a-col class="btn-item" v-if="!isSource && btnPermission('comfirmOutRet')" :class="voucherState == 1 || voucherState == 2 ?'':'btns-disable'">
            <!--退货入库修改后的入库 出库 -->
            <a-dropdown v-if="showModel=='order'" class="btns"  style="display:block">
                <a class="ant-dropdown-link" @click="e => e.preventDefault()">
                    <a-icon class="btns-icon" type="gold" />
                    <div class="btns-text">入库
                        <a-icon type="down" style="vertical-align:middle;" />
                    </div>
                </a>
                <a-menu slot="overlay">
                    <a-menu-item key="0">
                        <a href="javascript:void(0)" @click="voucherState==1?theGoods(3):''">
                            <span :class="editMask==true && voucherState==1 && orderId?'':'color-gray'">退货入库</span>
                        </a>
                    </a-menu-item>
                    <a-menu-item key="0">
                        <a href="javascript:void(0)" @click="voucherState==2?theGoods(2):''">
                            <span :class="editMask==true && voucherState==2 && orderId?'':'color-gray'">撤销退货</span>
                        </a>
                    </a-menu-item>
                </a-menu>
            </a-dropdown>
            <div v-else class="btns-disable">
                <a-dropdown class="btns"  style="display:block">
                    <a class="ant-dropdown-link" @click="e => e.preventDefault()">
                        <a-icon class="btns-icon" type="audit" />
                        <div class="btns-text">入库
                            <a-icon type="down" style="color:#ccc;vertical-align:middle;" />
                        </div>
                    </a>
                    <a-menu slot="overlay">
                        <a-menu-item key="0">
                            <a href="javascript:void(0)">
                                <span class="color-gray">退货入库</span>
                            </a>
                        </a-menu-item>
                        <a-menu-item key="0">
                            <a href="javascript:void(0)">
                                <span class="color-gray">撤销退货</span>
                            </a>
                        </a-menu-item>
                    </a-menu>
                </a-dropdown>
            </div>

        </a-col>

        <a-col class="btn-item" :class="voucherState==1?'':'btns-disable'" v-if="btnPermission('verification')">
            <div v-if="showModel=='order'">
                <div class="btns" @click="voucherState==1?verificationFun():''">
                    <a-icon class="btns-icon" type="build" />
                    <div class="btns-text">核销</div>
                </div>
            </div>
            <div v-else class="btns-disable">
                <div class="btns">
                    <a-icon class="btns-icon" type="build" />
                    <div class="btns-text">核销</div>
                </div>
            </div>
        </a-col>

        <!-- <a-col class="btn-item" v-show="showModel=='detail'">
            <div class="btns" @click="searchClick('detail')">
                <a-icon class="btns-icon" type="file-search" />
                <div class="btns-text">查询</div>
            </div>
        </a-col>
        <a-col class="btn-item" v-show="showModel=='statistical'">
            <div class="btns" @click="searchClick('statistical')">
                <a-icon class="btns-icon" type="file-search" />
                <div class="btns-text">查询</div>
            </div>
        </a-col> -->
        <a-col class="btn-item" :class="orderId?'':'btns-disable'" v-if="btnPermission('reportprice')">
            <div v-if="showModel=='order'">
                <div class="btns" @click="orderId?priceShow():''">
                    <a-icon class="btns-icon" type="transaction" />
                    <div class="btns-text">报价</div>
                </div>
            </div>
            <div v-else class="btns-disable">
                <div class="btns">
                    <a-icon class="btns-icon" type="transaction" />
                    <div class="btns-text">报价</div>
                </div>
            </div>
        </a-col>

        <slot name="moreBtn"></slot>
        <!-- <a-col class="btn-item" :class="voucherState==0 || voucherState==10 || voucherState==2?'btns-disable':''"> -->
        <a-col class="btn-item" :class="voucherState==-1 || voucherState ==0 || voucherState==10 || num == 0 ? 'btns-disable':''">
            <slot name="shengdan"></slot>
            <!-- <a-dropdown class="btns" key="sheng" style="display:block">
                    <a class="ant-dropdown-link" @click="e => e.preventDefault()">
                        <a-icon class="btns-icon" type="snippets" />
                        <div class="btns-text">生单
                            <a-icon type="down" />
                        </div>
                    </a>
                    <a-menu v-if="voucherState==1" slot="overlay">
                        <a-menu-item key="0">
                            <a href="javascript:void(0)" @click="generateBills('SaleOrder')">生成销售订单</a>
                        </a-menu-item>
                    </a-menu>
                </a-dropdown>-->
        </a-col>
        <a-col class="btn-item">
            <slot name="guanbi"></slot>
        </a-col>

        <a-col :class="domArray.length > 0?'btn-item':''" v-for="(b,index) in domArray" :key="index">
            &nbsp;
        </a-col>

        <a-col class="btn-item" v-if="btnPermission('statistic')">
            <div class="btns" @click="switchList('statistical')">
                <a-icon class="btns-icon" type="bar-chart" />
                <div class="btns-text">统计表</div>
            </div>
        </a-col>
        <a-col class="btn-item" v-if="btnPermission('detailList')">
            <div style="position:relative">
                <div class="btns" @click="switchList('detail')">
                    <a-icon class="btns-icon" type="read" />
                    <div class="btns-text">明细表</div>
                </div>
                <div style="position:absolute;width:2px;height:36px;border-radius:6px;background:#ccc;top:0px;right:0px;"></div>
            </div>
        </a-col>

        <!--更多-->
        <a-col class="btn-item" v-if="btnPermission('statistic')" :class="showModel=='detail' || showModel=='statistical'?'':'btns-disable'">
            <!--导出-->
            <div style="position:relative">
                <a-dropdown class="btns" key="export" style="display:block">
                    <a class="ant-dropdown-link" @click="e => e.preventDefault()">
                        <a-icon class="btns-icon" type="menu-unfold" />
                        <div class="btns-text">更多
                            <a-icon type="down" style="vertical-align:middle;" />
                        </div>
                    </a>
                    <a-menu slot="overlay">
                        <a-menu-item key="0">
                            <a href="javascript:void(0)" @click="showModel=='detail' || showModel=='statistical'?exportDetail():''">
                                <span>导出</span>
                            </a>
                        </a-menu-item>
                    </a-menu>
                </a-dropdown>
                <div style="position:absolute;width:2px;height:36px;border-radius:6px;background:#ccc;top:0px;right:0px;"></div>
            </div>
        </a-col>

        <a-col class="btn-item">
            <div :class="showModel=='order'?'':'btns-disable'">
                <div class="btns" @click="showModel=='order'?turnThePage(3):''">
                    <a-icon class="btns-icon" type="vertical-right" />
                    <div class="btns-text">首张</div>
                </div>
            </div>
        </a-col>
        <a-col class="btn-item">
            <div :class="showModel=='order'?'':'btns-disable'">
                <div class="btns" @click="showModel=='order'?turnThePage(1):''">
                    <a-icon class="btns-icon" type="left" />
                    <div class="btns-text">上张</div>
                </div>
            </div>
        </a-col>
        <a-col class="btn-item">
            <div :class="showModel=='order'?'':'btns-disable'">
                <div class="btns" @click="showModel=='order'?turnThePage(2):''">
                    <a-icon class="btns-icon" type="right" />
                    <div class="btns-text">下张</div>
                </div>
            </div>
        </a-col>
        <a-col class="btn-item">
            <div style="position:relative" :class="showModel=='order'?'':'btns-disable'">
                <div class="btns" @click="showModel=='order'?turnThePage(4):''">
                    <a-icon class="btns-icon" type="vertical-left" />
                    <div class="btns-text">末张</div>
                </div>
                <div style="position:absolute;width:2px;height:36px;border-radius:6px;background:#ccc;top:0px;right:0px;"></div>
            </div>
        </a-col>
        <a-col class="btn-item">
            <div style="position:relative">
                <div class="btns" @click="syncOrder">
                    <a-icon class="btns-icon" type="file-sync" />
                    <div class="btns-text">刷新</div>
                </div>
                <div style="position:absolute;width:2px;height:36px;border-radius:6px;background:#ccc;top:0px;right:0px;"></div>
            </div>
        </a-col>
        <a-col class="btn-item">
            <div class="btns" @click="printOrder">
                <a-icon class="btns-icon" type="printer" />
                <div class="btns-text">打印</div>
            </div>
        </a-col>
    </a-row>
</template>
<script>
import { mapState } from "vuex";
import btnpermiss from "@/utils/tool/btn-permissions"
import bomVue from '../../views/production/bom.vue';
export default {
    props: {
        showModel: { //当前展示状态
            type: Boolean,
            default: 'order'
        },
        orderId: {   //单据id
            type: Number
        },
        num:{
            type: Number
        },
        voucherState: {  //单据状态
            type: Number
        },
        editMask: {     //修改遮罩浮层
            type: Boolean,
            default: true
        },
        createUserId: {  //单据创建人
            type: String
        },
        isSource: {  //是否是生成的单据
            type: Boolean,
            default: false
        },
        sourceCode: {
            type: String
        },
        isRefund: {//是否是退料
            type: String,
        },
        enableState: {     //是否启用
            type: Boolean,
            default: false
        },
        hideRevocation: {
            type: Boolean,
            default: false,
        }
    },
    computed: {
        ...mapState({
            userInfo: state => state.user.info,
            permissions: state => state.user.permissions,
        }),
    },
    data () {
        return {
            domNum: 0,//显示按钮的数量
            domArray: [],//补足按钮个数
            styleNot: {
                'color': '#ccc'
            },
            path: this.$route.path,//当前页面路径
            //合同签订
            notSubmitArray: ['/contract/contractBills'],//不需要提交的 单据（路由）
        }
    },
    // mounted() {
    //     this.domNum = 0;
    //     this.domNum = document.getElementsByClassName('btn-item').length;
    //     console.log('tag', this.domNum)
    //     if (this.domNum < 24) {
    //         for (let i = 0; i < 24 - this.domNum; i++) {
    //             this.domArray.push({})
    //         }
    //     }
    // },
    activated () {
        this.domNum = 0;
        this.domNum = document.getElementsByClassName('btn-item').length;
        if (this.domNum < 24) {
            for (let i = 0; i < 24 - this.domNum; i++) {
                this.domArray.push({})
            }
        }
    },
    methods: {
        //显示模式
        switchList (type) {
            this.$emit('switchList', type);
        },

        //保存
        submitServer () {
            this.$emit('submitServer');
        },
        //修改
        clickEdit () {
            this.$emit('clickEdit');
        },
        //删除
        deleteOrder () {
            this.$emit('deleteOrder');
        },
        //撤销
        getIdByData () {
            this.$emit('getIdByData');
        },
        //审核||弃审
        auditClick (t) {
            this.$emit('auditClick', t);
        },
        //打印
        printOrder () {
            this.$emit('printOrder');
        },
        //翻页
        turnThePage (page) {
            this.$emit('turnThePage', page);
        },
        //收货
        theGoods (type) {
            this.$emit('theGoods',type)
        },
        //导出
        exportDetail () {
            this.$emit('exportDetail');
        },
        //变更
        bgChange () {
            this.$emit('bgChange');
        },
        //刷新
        syncOrder () {
            this.$emit('syncOrder');
        },
        searchClick (type) {
            //搜索
            this.$emit('searchClick', type);
        },
        submitClick () {
            //提交销售发货单
            this.$emit('submitClick');
        },
        submitOrder (type) {
            //提交单据
            this.$emit('submitOrder', type);
        },
        approvalClick (t) {
            //批准
            this.$emit('approvalClick', t);
        },
        changeEnableState (t) {
            //启用/停用
            this.$emit('changeEnableState', t);
        },
        allotClick () {
            //调拨
            this.$emit('allotClick');
        },
        returnBack () {
            //调拨退单
            this.$emit('returnBack');
        },
        verificationFun () {
            //财务核销
            this.$emit('verificationFun');
        },
        priceShow () {
            //汇报价格（新西亚）
            this.$emit('priceShow');
        },
        //按钮的权限控制
        btnPermission (behind) {
            let parameter = {
                path: this.$route.path,//当前页面路径
                behind: behind,//权限后半段标识
                permissionAll: this.permissions,//当前用户所有的权限标识
            }
            return btnpermiss.btnPermission(parameter);
        }

    }
}
</script>
<style lang="less">
    .btn-box {
        display: flex;
        .btn-item {
            flex: 1;
            width: 10%;
        }
    }
    .color-gray {
        color: #ccc !important;
    }
</style>